package com.woniuxy.controller;

import com.woniuxy.entity.Constants;
import com.woniuxy.entity.ResultVO;
import com.woniuxy.entity.User;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : mafan
 * @date : 2020-11-18 20:19
 **/
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("save")
    public ResultVO save(@RequestBody User user) {
        ResultVO resultVO = null;
        try {
            userService.save(user);
            resultVO = new ResultVO(Constants.OPER_SUCCESS, "用户添加成功",user);
        } catch (Exception e) {
            e.printStackTrace();
            resultVO = new ResultVO(Constants.OPER_SUCCESS, "用户添加失败");
        }
        return resultVO;
    }
}
